Skip to content

docs: update example#13061

Merged
kgryte merged 2 commits into
developfrom
philipp/ci-fix-random-examples-ndarray-from-scalar-2026-06-22
Jun 23, 2026
Merged

docs: update example#13061
kgryte merged 2 commits into
developfrom
philipp/ci-fix-random-examples-ndarray-from-scalar-2026-06-22

Conversation

@Planeshifter

Copy link
Copy Markdown
Member

Description

This pull request:

  • Adds a guard in @stdlib/ndarray/from-scalar example to skip float16 and complex32 dtypes, whose buffer constructors in @stdlib/ndarray/base/buffer-ctors are placeholder notImplemented functions that throw Error: not implemented when invoked as constructors.

The example iterates over all dtypes returned by dtypes() (which includes every registered dtype in dtypes.json). For float16 and complex32, the internal call chain is:

scalar2ndarray(i, { dtype: 'float16' })
  → buffer('float16', 1)
    → bufferCtors('float16')   // returns notImplemented (truthy)
      → new notImplemented(1)  // throws Error: not implemented

The if (buf === null) guard in from-scalar/lib/main.js never fires because the throw happens before buffer() can return. The fix skips these two dtypes in the example until their constructors are implemented (tracked by the FIXME comments in buffer-ctors/lib/ctors.js).

This resolves the random_examples CI job failure seen in workflow run 27923327635.

Related Issues

  • No dedicated issue; failure surfaced via CI job random_examples on develop.

Questions

No.

Other

No.

Checklist

AI Assistance

  • Yes

  • Code generation (e.g., when writing an implementation or fixing a bug)

  • Research and understanding

Disclosure

This PR was written primarily by Claude Code as part of an automated CI failure investigation routine. The root cause was identified by tracing the call chain from the failing example through @stdlib/ndarray/base/buffer and @stdlib/ndarray/base/buffer-ctors. The fix was validated by running the example locally and by three independent automated reviewers (correctness, regression, and style checks).


@stdlib-js/reviewers


Generated by Claude Code

The example iterates over all ndarray dtypes, including `float16` and
`complex32`, whose buffer constructors in `@stdlib/ndarray/base/buffer-ctors`
are placeholder `notImplemented` functions that throw `Error: not implemented`
when invoked. Add a guard to skip these two dtypes until their constructors are
implemented.

Fixes CI job `random_examples` failure.
@stdlib-bot

stdlib-bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

No coverage information available.

Comment thread lib/node_modules/@stdlib/ndarray/from-scalar/examples/index.js Outdated
Comment thread lib/node_modules/@stdlib/ndarray/from-scalar/examples/index.js Outdated
Co-authored-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
@kgryte kgryte marked this pull request as ready for review June 23, 2026 05:16
@kgryte kgryte requested a review from a team June 23, 2026 05:16
@kgryte kgryte added the Documentation Improvements, additions, or changes to documentation. label Jun 23, 2026
@kgryte kgryte changed the title fix: skip unimplemented dtypes in from-scalar example docs: update example Jun 23, 2026
@kgryte kgryte merged commit 4b3d572 into develop Jun 23, 2026
33 checks passed
@kgryte kgryte deleted the philipp/ci-fix-random-examples-ndarray-from-scalar-2026-06-22 branch June 23, 2026 05:35
@stdlib-bot stdlib-bot added Needs Review A pull request which needs code review. and removed Needs Review A pull request which needs code review. labels Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improvements, additions, or changes to documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants